$(function () {
    $('#myTable').dataTableExtend({
        "ajax": sysInfo.basePath + "/zs/credential/qualification_transfer/get_rejected_record.do",
//			    	"select":true,
        "scrollX": "true",//是否开启横项滚动
        "fixedColumns": {//锁定列，只有开启scrollX时才生效
            "leftColumns": 4,//左侧锁定2列
            // "rightColumns": 1//右侧锁定1列
        },
        "fnServerParams": function (aoData) {
            //搜索条件
            var checkResult = checkHasSybAuth($("#signOrgId option"));
            if (!checkResult) {
                aoData.isAll = "0";
            } else {
                aoData.signOrgId = $("#signOrgId").val();
            }
            aoData.certificateType = $("#certificateType").val();
            aoData.qualificationName = $("#certificateSpecialty").val();
            if ($('[name="certificateLevel"]').val()) {
                aoData.certificateLevel = $('[name="certificateLevel"]').val();
            }
            aoData.applicationScope = $("#applicationScope").val();
            aoData.certificateArea = $("#certificateAreaCodes").val();
            aoData.keyword = $("#keyword").val();
        },
        "aoColumns": [
            {
                "title": "序号",
                "orderable": false,
                "render": function (data, type, full, meta) {
                    return meta.row + 1;
                }
            },
            {
                "title": "所属事业部",
                "data": "signOrgName",
                "orderable": false
            },
            {
                "title": "关联生产订单",
                "data": "scOrderNo",
                "orderable": false,
                "render": function (data, type, row, meta) {
                    if (!data) {
                        return "";
                    }
                    return "<a href='javascript:void(0);'  class='layui-table-link' onclick='openOrderInfoDetail(\"" + data + "\",\"" + row.scOrderId + "\")'>" + data + "</a>";
                }
            },
            {
                "title": "资质编号",
                "data": "certificateNo",
                "orderable": false,
                "render": function (data, type, full, meta) {
                    return "<a href='javascript:void(0);'  class='layui-table-link' onclick='qualificationDetails(\"" + data + "\",\"" + full.baseId + "\")'>" + data + "</a>";
                }
            },
            {
                "title": "所属企业",
                "data": "originalCompany",
                "orderable": false
            },
            {
                "title": "资质有效期",
                "data": "certificateExpiryTime",
                "orderable": false,
                "render":function (data) {
                    if (!data) {
                        return "";
                    }
                    return data.substring(0,10);
                }
            },
            {
                "title": "资质类型",
                "data": "certificateType",
                "orderable": false
            },
            {
                "title": "资质名称",
                "data": "qualificationName",
                "orderable": false,
                "render": function (data, type, row, meta) {
                    data = (null != data && "" != data) ? data : "";
                    return "<div title='" + data + "' class='f-toe' style=\"max-width:100px;word-wrap:break-word\">" + data + "</div>";
                }
            },
            {
                "title": "资质等级",
                "data": "certificateLevel",
                "orderable": false
            },
            {
                "title": "成本价格（元）",
                "data": "receiptPrice",
                "orderable": false,
                "render": function (data) {
                    return fmtMoney(data);
                }
            },
            {
                "title": "转让价格（元）",
                "data": "certificatePrice",
                "orderable": false,
                "render": function (data) {
                    return fmtMoney(data);
                }
            },
            {
                "title": "审核人",
                "data": "currentAuditerName",
                "orderable": false
            },
            {
                "title": "地区",
                "data": "certificateArea",
                "orderable": false,
                "render": function (data, type, row, meta) {
                    areaProvince = (null != row.areaProvince && "" != row.areaProvince) ? row.areaProvince : "";
                    area = (null != row.certificateArea && "" != row.certificateArea) ? "/" + row.certificateArea : "";
                    return areaProvince + area;
                }
            },
            {
                "title": "适用范围",
                "data": "applicationScope",
                "orderable": false
            },
            {
                "title": "操作",
                "orderable": false,
                "data": "id",
                "render": function (data, type, full, meta) {
                    return '<a onclick="checkDetails(\'' + data + '\')" class="iboss-link"  style="cursor:pointer">查看</a>';
                }
            }
        ],
    });

    syb('#signOrgId');
    loadCertificateType('190px','#certificateType', $("#generalType").val(), 0);
    //异步加载地区
    Plug.plug_ins(
        "get",
        cmsBaseUrl + "/api/cms/tree_book/v1/get_tree_book_list.do?code=2147483647&type=2&level=1",
        "#certificateArea",
        '请选择地区',
        function () {
        },
        true, '2147483647'
    );
});6

/**
 * 导出驳回数据
 */
function exportRejectedRecord() {
    var params = {};
    var checkResult = checkHasSybAuth($("#signOrgId option"));
    if (!checkResult) {
        params["isAll"] = "0";
    } else {
        params["signOrgId"] = $("#signOrgId").val();
    }
    params["certificateType"] = $("#certificateType").val();
    params["qualificationName"] = $("#certificateSpecialty").val();
    if ($('[name="certificateLevel"]').val()) {
        params["certificateLevel"] = $('[name="certificateLevel"]').val();
    }
    params["applicationScope"] = $("#applicationScope").val();
    params["certificateArea"] = $("#certificateAreaCodes").val();
    params["keyword"] = $("#keyword").val();
    var check = false;
    for (let index in params) {
        if (params[index]) {
            check = true;
            break;
        }
    }
    if (!check) {
        DGG.Errors("请选择搜索条件后进行导出!");
        return false;
    }
    export_table("/zs/credential/qualification_transfer/export_rejected_record.do", params);
}

/**
 * 查看详情
 * @param id
 */
function checkDetails(id) {
    DGG.loading();
    $.post(sysInfo.basePath + "/zs/credential/qualification_transfer/get_record_details.html?transferId="+id, function (data) {
        DGG.loading('close');
        var index = dgg.Open({
            type: 1,
            title: '记录详情',
            content: data,
            area: '600px',
        })
    }, 'html');
}